CREATE TABLE [dbo].[TMVALO_LIMI]
(
[CO_EMPR] [dbo].[TD_VC_002] NOT NULL,
[CO_CNTA_EMPR] [dbo].[TD_VC_020_CNTA] NOT NULL,
[NU_ANNO] [dbo].[TD_IN_004_ANNO] NOT NULL CONSTRAINT [DF__TMVALO_LI__NU_AN__68D28DBC] DEFAULT (datepart(year,getdate())),
[TI_AUXI_EMPR] [dbo].[TD_VC_001] NOT NULL,
[CO_AUXI_EMPR] [dbo].[TD_VC_020] NOT NULL,
[IM_VALO_LIMI] [dbo].[TD_NU_016_004] NULL CONSTRAINT [DF__TMVALO_LI__IM_VA__6ABAD62E] DEFAULT ((0)),
[CO_USUA_CREA] [dbo].[TD_VC_008_USUA] NOT NULL,
[FE_USUA_CREA] [dbo].[TD_DT_001_SIST_] NOT NULL,
[CO_USUA_MODI] [dbo].[TD_VC_008_USUA] NOT NULL,
[FE_USUA_MODI] [dbo].[TD_DT_001_SIST_] NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[TMVALO_LIMI] ADD CONSTRAINT [CK__TMVALO_LI__CO_CN__67DE6983] CHECK (([CO_CNTA_EMPR]>='0' AND [CO_CNTA_EMPR]<='99999999999999999999'))
GO
ALTER TABLE [dbo].[TMVALO_LIMI] ADD CONSTRAINT [CK__TMVALO_LI__IM_VA__6BAEFA67] CHECK (([IM_VALO_LIMI]>=(0)))
GO
ALTER TABLE [dbo].[TMVALO_LIMI] ADD CONSTRAINT [CK__TMVALO_LI__NU_AN__69C6B1F5] CHECK (([NU_ANNO]>=(0)))
GO
ALTER TABLE [dbo].[TMVALO_LIMI] ADD CONSTRAINT [XPKTMVALO_LIMI] PRIMARY KEY CLUSTERED  ([CO_EMPR], [CO_CNTA_EMPR], [NU_ANNO], [TI_AUXI_EMPR], [CO_AUXI_EMPR]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[TMVALO_LIMI] ADD CONSTRAINT [TMPLAN_ANNO_A_TMVALO_LIMI] FOREIGN KEY ([CO_EMPR], [CO_CNTA_EMPR]) REFERENCES [dbo].[TMPLAN_ANNO] ([CO_EMPR], [CO_CNTA_EMPR])
GO
